Skip to content

Conversation

taekwon-dev
Copy link
Contributor

@taekwon-dev taekwon-dev commented Sep 9, 2024

답안 제출 문제

체크 리스트

  • PR을 프로젝트에 추가하고 Week를 현재 주차로 설정해주세요.
  • 바로 앞에 PR을 열어주신 분을 코드 검토자로 지정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 Status를 In Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.


StringBuilder sb = new StringBuilder();
for (int i = 0; i < 26; i++) {
sb.append("^").append(count[i]);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note:

StringBuilder 에 appending 할 때 "^" 와 같이 구분자를 넣어야 하는 이유

  • [2, 0, 1] -> "201"
  • [20, 1] -> "201"

위와 같은 케이스가 발생함. 따라서 구분자를 넣어서 이와 같은 충돌 케이스를 방지함.

Comment on lines +1 to +7
/**
* 시간 복잡도: O(n)
* - 문제 조건 1 <= prices.length <= 10^5 를 보고, 우선 O(n^2)는 피해야겠다는 생각을 우선하게 됨.
* - 결국 이 문제는 각 인덱스가 날짜 개념으로 적용되기 때문에, 순차적으로 흘러감. (최대 이익을 계산할 때 결국 각 일자 별로 내가 얼마의 이득을 봤는지를 계산하고, 이 중 최댓값을 고르면 되는 구조)
* - 따라서 한 번의 순회로 문제를 풀 수 있음
* 공간 복잡도: O(1)
*/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

접근 방식을 잘 작성해주셔서 이해가 잘 되었습니다 👍

@taekwon-dev taekwon-dev marked this pull request as ready for review September 14, 2024 01:18
@taekwon-dev taekwon-dev requested a review from a team as a code owner September 14, 2024 01:18
Copy link
Contributor

@bky373 bky373 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

고생하셨습니다~

@taekwon-dev taekwon-dev merged commit 3df3ec8 into DaleStudy:main Sep 14, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

2 participants